'''
Created on Sep 20, 2011

@author: haddaway
'''

class Config():
    '''
    This is the basic config that is applied to Helios
    '''
    def __init__(self):
        '''
        Constructor
        '''
        ### COMMUNICATION ###
        self.serialPort = '/dev/ttyACM0'  # Connection port for Arduino
        self.serialRate = 9600            # System transfer speed
        self.heliosListenDuration = 100   # Queue read from every x milliseconds
        self.packetSize = 32              # Size of packet in nibbles (4 bits)
        self.rawPacketSize = 4096         # Size of packet in bits
        self.newLineSize = 2              # Size variable for newline character at end of packet
        
        ### LOGGING ###
        self.minLogPriority = 1           # Minimum alert priority for logging
        self.logName = 'Helios.log'       # Name of log file to be used

        ### DEVICE CODES ###
        self.deviceTypes = {
                            "0000":"Uninitialized Device",
                            "0001":"Helios",
                            # Sensor-type Modules
                            "0002":"Laser Tripwire",
                            "0003":"Window Open Sensor",
                            "0004":"Motion Camera",
                            "0005":"RFID Sensor",
                            "0006":"Card Reader",
                            "0007":"Sonar",
                            "0008":"Vibration Detector",
                            "000A":"Door Open Sensor",
                            "000B":"Light Lock Receiver",
                            "000C":"Light Lock Transmitter",
                            # Action-type Modules
                            "0009":"Door Unlocker",
                            "000D":"Flood Lights",
                            "000E":"Microphone",
                            
                            "000F":"Cellphone"
                            }
        
        ### STATUS CODES ###
        self.statusTypes = {
                            # Universal statuses
                            "C0DE":"Debug",
                            "DEAD":"Death Event",
                            "0001":"Initialization",
                            "1000":"Device ID Assignment",
                            "00FF":"Heartbeat",
                            # Laser Tripwire Statuses
                            "0201":"Stream Broken",
                            "0202":"Modulation Change Detected",
                            # Window Open Sensor Statuses
                            "0301":"Circuit Broken",
                            # Motion Camera Statuses
                            # RFID Sensor Statuses
                            "0501":"Authorization Requested",
                            # Card Reader Statuses
                            "0601":"Authorization Requested",
                            # Sonar Statuses
                            "0701":"Echo Signature Determined",
                            "0702":"New Echo Signature Detected",
                            # Vibration Detector Statuses
                            "0801":"Vibration Detected",
                            # Door Unlocker Statuses
                            "0901":"Door Unlocked",
                            # Door Open Sensor Statuses
                            "0A01":"Door Opened",
                            # Light Lock Receiver Statuses
                            "0B01":"Authorization Requested",
                            # Light Lock Transmitter Statuses
                            # Flood Lights Statuses
                            # Microphone Statuses
                            # Cellphone Statuses
                            }
        
        
        self.currentDevices = {}          # Dictionary of devices initialized or in the process
        self.initializationDelay = 1.5      # Delay in s between resending initialization packet
        self.initializationTimeout = 10   # Number of initialization packets to send before giving up
        self.packetSet = set()
        self.lightLockCodes ={
                            "FFFABDFF":"Iggy Krajci"
                            }
        
config = Config()